const { tabList, productList } = require("./mock");

module.exports = (app) => {
  app.get("/api/tab/list", (req, res) => {
    res.send({
      code: 200,
      data: tabList,
    });
  });

	app.get("/api/product/list", (req, res) => {
    res.send({
      code: 200,
      data: productList,
    });
  });

	app.get('/api/detail', (req, res) => {
		const { id } = req.query;
		const item = productList.find(v => v.id === id);

		if(item) {
			res.send({
				code: 200,
				data: item
			})
		} else {
			res.send({
				code: 404
			})
		}
	})
};
